<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0" style=" border:3px #FFFFFF solid;">
    <tr>
        <td align="center" colspan="2" height="25" bgcolor="#800080" style=" border:0; border-bottom:#FFFFFF 1px solid;">
            <font color='#FFFFFF' style='font-weight:bold'><?php echo $this->product->name;?></font>
        </td>
    </tr>
    <tr>
        <td width="45%" align="center">
            <img width="200" src="<?php echo $this->baseUrl();?>/images/product/<?php echo $this->product->url;?>">
        </td>
        <td align="left" valign="top"><br>
            <b>- Product name:</b>&nbsp;<?php echo $this->product->name;?><br>
            <b>- Price:</b>&nbsp;<?php echo $this->product->price;?>$<br>
            <b>- Weight:</b>&nbsp;<?php echo $this->product->size;?>&nbsp;kg<br>
            <b>- Warranty:</b>&nbsp;<?php echo $this->product->warranty;?>&nbsp;years<br>
            <br>
            <form action="<?php echo $this->url(array('controller'=>'order','action'=>'addproduct','id'=>$this->product->id)); ?>" method ="POST">
            Quantity: <input type="text" size="4" name="quantity" value="1">&nbsp;
            <input type="submit" style="background-color:#800080; color:#FFFFFF" value="Add to cart">
            </form>
        </td>
    </tr>
</table>

<?php $cmt = new CommentDao();
      $acc = new AccountDao();

      $commentList = $cmt->getComment($this->product->id);
      
      $userSession = new Zend_Session_Namespace('user');
      $user_id = $userSession->user_id;
      $row = $acc->getUser($user_id);
      if ($row['role_id'] == 2){
?>

<table class="mytable" width="40">
<tr>
    <th>User</th>
    <th>Comment</th>
</tr>

<?php foreach($commentList as $commenttb) :
      $user = $acc->getUser($commenttb->user_id);
      ?>
<tr>
    <td><?php echo $user['username'];?></td>
    <td><?php echo $this->escape($commenttb->comment);?></td>
</tr>

<?php endforeach; ?>
</table>

<form action="<?php echo $this->url(array('module'=>'user', 'controller'=> 'comment', 'action'=>'add')); ?>" method="post">
    <table>
        <tr>
            <th>Comment Content:</th>
        </tr>

       <textarea name="comment" cols="40" rows="5"></textarea>

       <tr><td/><td><input type="hidden" name="product_id" value="<?php echo $this->product->id;?>" /></td></tr>
        <tr><td/><td><input type="submit" name="submit" value="  Add  " /></td></tr>
    </table>
</form>

<?php
      }
else
{
?>
<table class="mytable" width="2">
<tr>
    <th>User</th>
    <th>Comment</th>
    <th>&nbsp;</th>
</tr>
<?php foreach($commentList as $commenttb) :
      $user = $acc->getUser($commenttb->user_id);
      ?>
<tr>
    <td><?php echo $user['username'];?></td>
    <td><?php echo $this->escape($commenttb->comment);?></td>
    <td>
        <a href="<?php echo $this->url(array('module' => 'admin', 'controller'=>'comment',
            'action'=>'update','comment_id'=>$this->escape($commenttb->id)));?>">Edit</a>
        <a href="<?php echo $this->url(array('module' => 'admin', 'controller'=>'comment',
            'action'=>'delete','comment_id'=>$this->escape($commenttb->id)));?>">Delete</a>
    </td>
</tr>
<?php endforeach; ?>
</table>
<form action="<?php echo $this->url(array('module'=>'user', 'controller'=> 'comment', 'action'=>'add')); ?>" method="post">

       <tr>
            <th>Comment Content:</th>
       </tr>

       <textarea name="comment" cols="40" rows="5"></textarea>

       <tr><td/><td><input type="hidden" name="product_id" value="<?php echo $this->product->id;?>" /></td></tr>
       <tr><td/><td><input type="submit" name="submit" value="  Add  " /></td></tr>
    
</form>

<?php
}
?>
